/**
 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LIBPANDAFILE_SOURCE_LANG_ENUM_H
#define LIBPANDAFILE_SOURCE_LANG_ENUM_H

#include <array>
#include <cstdint>

#include "libpandabase/macros.h"
#include "source_language.h"

namespace ark::panda_file {

using SourceLang = SourceLanguage;

constexpr uint8_t LANG_COUNT = <%= Common::plugins.length + 1 %>;

constexpr std::array<SourceLang, ark::panda_file::LANG_COUNT> LANG_ITERATOR = {
% Common::plugins.each do |plugin_lang, plugin_opts|
    <%= plugin_opts["lang_enum"] %>,
% end
    ark::panda_file::SourceLang::PANDA_ASSEMBLY
};

static constexpr size_t GetLangArrIndex(panda_file::SourceLang lang)
{
    for (size_t index = 0; index < ark::panda_file::LANG_ITERATOR.size(); ++index) {
        if (ark::panda_file::LANG_ITERATOR[index] == lang) {
            return index;
        }
    }

    UNREACHABLE();
    return 0;
}


// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define LANG_ENUM_LIST   \
% Common::plugins.each_value do |plugin_opts|
    <%= plugin_opts["lang_enum"] %>, \
% end
    ark::panda_file::SourceLang::PANDA_ASSEMBLY

}  // namespace ark::panda_file

#endif  // LIBPANDAFILE_SOURCE_LANG_ENUM_H
